#!/bin/bash

# 获取当前脚本所在的目录
TEST_DIR="$(cd "$(dirname "$0")"; pwd)"

# 安装DT依赖
python3 -m pip install -r $TEST_DIR/requirements.txt

# 获取项目根目录 (test 的父目录)
PROJECT_DIR="$(dirname "$TEST_DIR")"

rm -rf ./result
mkdir -p ./result

#将deployer加入python path
export PYTHONPATH=$PROJECT_DIR:$PYTHONPATH

# 执行 Python 测试并计算覆盖率
python3 -m pytest $TEST_DIR --junitxml=./final.xml --html=./final.html --self-contained-html
coverage xml -i
cp coverage.xml final.xml final.html ./result
rm -rf coverage.xml final.xml final.html